<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;

class Article extends Model
{
    protected $fillable = ['title', 'content', 'published_at', 'user_id'];

    protected $dates = ['published_at'];

    public function scopePublished($query){
        $query -> where('published_at', '<=', Carbon::now());
    }

    public function user(){
        return $this -> belongsTo('App\User');
    }
}
